home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-04-25 | 14.9 KB | 472 lines | [TEXT/MPS ] |
- //========================================================================================
- // File: FWViews.fr
- // Release Version: $ ODF 1 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //========================================================================================
-
- #ifndef FWVIEWS_FR
- #define FWVIEWS_FR
-
- #ifndef FWARCOBJ_FR
- #include "FWArcObj.fr"
- #endif
-
- #ifndef FWSTRING_FR
- #include "FWString.fr"
- #endif
-
- #ifndef FWVIEWS_K
- #include "FWViews.k"
- #endif
-
- #ifndef SLGCONST_K
- #include "SLGConst.k"
- #endif
-
- //========================================================================================
- // type FW_RFixed
- //========================================================================================
-
- #if 0
- type FW_RFixed
- {
- IntBits:
- integer;
- FracBits:
- integer = 0;
- };
- #else
- #define FW_RFixed longint
- #endif
-
- // Handy macros for fixed coordinates
- // (You're welcome to define shorter macros in your own resource files!)
-
- #define FW_FIX(x) ((x)*65536)
-
- #define FW_ONE FW_FIX(1)
-
- // This macro cannot be used for now because of a bug in ODFRC...
- #define FW_BOUNDS(l,t,r,b) { FW_FIX(l),FW_FIX(t),FW_FIX(r),FW_FIX(b)}
-
- //========================================================================================
- // type FW_RPoint
- //========================================================================================
-
- type FW_RPoint
- {
- X:
- FW_RFixed;
- Y:
- FW_RFixed;
- };
-
- //========================================================================================
- // type FW_RRect
- //========================================================================================
-
- type FWRRect
- {
- Left:
- FW_RFixed;
- Top:
- FW_RFixed;
- Right:
- FW_RFixed;
- Bottom:
- FW_RFixed;
- };
-
- //========================================================================================
- // type FW_RFont
- //========================================================================================
-
- type FW_RFont(FW_kFontType)
- {
- FontSize:
- FW_RFixed;
- FontStyle:
- integer;
- FontName:
- FW_RStringData;
- };
-
- // Standard fonts defined in "SLGConst.k"
- #define FW_NORMAL_FONT { FW_FIX(12), FW_kPlain, "applFont" } // = Geneva on US systems
- #define FW_SYSTEM_FONT { FW_FIX(12), FW_kPlain, "systemFont" } // = Chicago on US systems
- #define FW_HELVETICA12 { FW_FIX(12), FW_kPlain, "Helvetica" }
- #define FW_TIMES12 { FW_FIX(12), FW_kPlain, "Times" }
- #define FW_COURIER12 { FW_FIX(12), FW_kPlain, "Courier" }
- #define FW_PALATINO12 { FW_FIX(12), FW_kPlain, "Palatino" }
-
- //========================================================================================
- // type FW_RRadioCluster
- //========================================================================================
-
- type FW_RRadioCluster : FW_RArchivableObject(Label='rcls')
- {
- // Hidden fields keeping a reference to the superview containing the radio buttons
- integer = FW_kPrivIDOnly;
- ViewClass:
- longint = gSuperViewClassID;
- integer = FW_kPrivIDOnly;
- ViewID:
- longint = gSuperViewObjectID;
-
- // ---- RadioCluster fields
-
- longint; // Dummy field needed to work around an odfrc bug
-
- RadioButtons: // List of radio button ids
- integer = $$CountOf(RadioArray);
- array RadioArray
- {
- RadioId: // The first radio in the list is turned on by default
- longint;
- };
- };
-
- //========================================================================================
- // type FW_RView
- //========================================================================================
-
- type FW_RView : FW_RArchivableObject(Label='view')
- {
- // Hidden fields keeping a reference to its superview used in the view's initialization
- integer = FW_kPrivIDOnly;
- ParentViewClass:
- longint = FW_kPrivNULLObjectID;
- integer = FW_kPrivIDOnly;
- ParentViewID:
- longint = FW_kPrivNULLObjectID;
-
- // ---- View fields
- ViewID:
- longint; // Must be unique within the same superview only
- // or leave it to 0 if you don't need to access this view
- Bounds:
- FWRRect; // MUST BE FIXED COORDINATES!! Use FW_FIX macro
- Binding:
- longint; // Use FW_kFixedBounds by default, see constants in "FWViews.k"
- };
-
- //========================================================================================
- // type FW_RSuperView
- //========================================================================================
-
-
- type FW_RSuperView : FW_RView(Label='suvw')
- {
- // Automatic variables used to define subviews with a reference back to this superview
- auto ownerClass = gClassID;
- auto ownerView = gObjectID;
-
- // Variables used in FW_RRadioCluster to keep a reference back to this superview
- // [LSD] this doesn't work if one of the subviews is also a superview because
- // the statics will be modified before being used in FW_RRadioCluster, but this
- // should be a rare case. The correct solution is to move these lines AFTER
- // the list of subviews, but odfrc doesn't like it for superviews without clusters!
- set gSuperViewClassID = ownerClass;
- set gSuperViewObjectID = ownerView;
-
- // ---- SuperView fields
- Extent:
- FW_RPoint; // MUST BE FIXED COORDINATES!! Use FW_FIX macro
- IsContentView:
- FW_RBoolean; // Use 1 to define your content view (= frame by default)
- ScrollingDirection:
- integer; // 0, FW_kXscrolling, FW_kYscrolling or FW_kXYscrolling
-
- SubViews: // List of SubViews
- integer = $$CountOf(SubViewArray);
- array SubViewArray
- {
- FW_RView(ParentViewClass=ownerClass, ParentViewID=ownerView);
- };
-
- #if 0
- // ODFRC bug: cannot add a second array in this resource type for now...
- // RadioClusters must be defined in your own resource type (see Form example)
- RadioClusters:
- integer = $$CountOf(RadioClusterArray);
- array RadioClusterArray
- {
- FW_RRadioCluster(ViewClass=ownerClass, ViewID=ownerView);
- };
- #endif
- };
-
- //========================================================================================
- // type FW_RControl
- //========================================================================================
- // FW_RControl is an abstract type, you shouldn't create resources directly from that type
-
- type FW_RControl : FW_RView(Label='cont')
- {
- Message:
- longint; // 0 by default, or message to be sent when control's value changes
- // Note: use FW_kDefaultButtonMsg & FW_kCancelButtonMsg to define OK and
- // Cancel buttons in dialogs (you must #include "FWNotDef.h")
- Receiver:
- integer; // use 0 by default (no receiver), or FW_kViewReceiver or FW_kFrameReceiver
- // Normally only for push buttons. No effect on scrollbars.
-
- InitialValue:
- longint; // 0 by default, 1 for buttons to turn on, X for scroll-bars, etc.
- };
-
- //========================================================================================
- // type FW_RNativeControl
- //========================================================================================
- // FW_RNativeControl doesn't add any fields to FW_RControl
-
- type FW_RNativeControl : FW_RControl(Label='nctl')
- {
- };
-
- //========================================================================================
- // type FW_RButton
- //========================================================================================
-
- type FW_RButton : FW_RNativeControl(Label='butn')
- {
- ButtonKind:
- longint; // FW_kPushButton, etc. See "FWViews.k"
- Font:
- FW_RFont; // Use FW_SYSTEM_FONT by default
- Title:
- FW_RStringData; // Button label
- };
-
- //========================================================================================
- // type FW_RPopupMenu
- //========================================================================================
-
- type FW_RPopupMenu : FW_RNativeControl(Label='popm')
- {
- MacMenuId:
- unsigned integer; // 'MENU' resource id
- TitleWidth:
- integer; // 0 by default
- InitialMenuItem:
- integer; // 1 by default
- MenuVariation:
- unsigned integer; // See variant codes for pop-up menu in <controls.h>
- MenuRefCon:
- longint; // Used with previous field ('FONT' to display font resources)
- Font:
- FW_RFont; // Use FW_SYSTEM_FONT by default
- Title:
- FW_RStringData; // (odfrc bug: string must be the last field)
- };
-
- //========================================================================================
- // type FW_RScrollBar
- //========================================================================================
- // Scrollbar resource fields are only important if the scrollbar is used as a separate
- // control (i.e. not associated with a Scroller).
- // In most cases the scrollbar is attached to a Scroller which will adjust these values
- // automatically.
-
- type FW_RScrollBar : FW_RNativeControl(Label='scbr')
- {
- MinValue:
- integer; // use 0 by default
- MaxValue:
- integer; // use 1 by default
- MinorUnits:
- FW_RFixed; // use FW_ONE by default
- MajorUnits:
- FW_RFixed; // use FW_ONE by default
- };
-
- // Default scrollbar size (Macintosh)
- #define FW_SBSIZE FW_FIX(15)
-
- // ODFRC bug: cannot use macros with more than 1 argument for now...
- // Standard vertical & horizontal scrollbar bounds inside a frame of size (h,v)
- #define FW_STDVERTICALSB(h,v) {h - FW_SBSIZE, -FW_ONE, h + FW_ONE, v - FW_SBSIZE + FW_ONE}
- #define FW_STDHORIZONTALSB(h,v) {-FW_ONE, v - FW_SBSIZE, h - FW_SBSIZE + FW_ONE, v + FW_ONE}
-
- //========================================================================================
- // type FW_RGrowBox
- //========================================================================================
-
- type FW_RGrowBox : FW_RView(Label='grbx')
- {
- };
-
- // ODFRC bug: cannot use macros with more than 1 argument for now...
- // Standard growbox bounds inside a frame of size (h,v)
- #define FW_STDGROWBOX(h,v) {h - FW_SBSIZE, v - FW_SBSIZE, h + FW_ONE, v + FW_ONE}
-
- //========================================================================================
- // type FW_RListBox
- //========================================================================================
-
- type FW_RListBox : FW_RView(Label='lbox')
- {
- NumRows:
- integer; // Initial number of rows (can change at runtime)
- VerticalSB:
- FW_RBoolean; // = 1 by default to have a scrollbar
- SingleSelection:
- FW_RBoolean; // 0 -> multiple selections, 1 -> single selection
- UseFocusFrame:
- FW_RBoolean; // Use 1 to draw a frame when list has keyboard focus
- UseClientData:
- FW_RBoolean; // Use 1 to store 32bit values in 2nd hidden column
- DblClickMessage:
- longint; // 0 -> list uses default FW_kListBoxDoubleClickedMsg message
- Font:
- FW_RFont; // Use FW_NORMAL_FONT by default
- StringItems:
- integer = $$CountOf(ItemsArray);
- array ItemsArray
- {
- FW_RStringData; // List of string items (or leave "{ }" if empty)
- };
- };
-
- //========================================================================================
- // type FW_RStaticText
- //========================================================================================
-
- type FW_RStaticText : FW_RView(Label='stxt')
- {
- Font:
- FW_RFont; // Use FW_NORMAL_FONT by default
- Text:
- FW_RStringData;
- };
-
- //========================================================================================
- // type FW_RGroupBox
- //========================================================================================
-
- type FW_RGroupBox : FW_RStaticText(Label='gpbx')
- {
- // A GroupBox doesn't add any field to a StaticText, it's just drawn differently
- };
-
- //========================================================================================
- // type FW_REditView
- //========================================================================================
-
- type FW_REditView : FW_RView(Label='edvw')
- {
- MaxChars:
- integer;
- Attributes:
- integer; // Use bit values defined in "FWEdView.h"
- // Default should be 13 = kDrawBox + kWordWrap + kAutoScroll
- Font:
- FW_RFont; // Use FW_NORMAL_FONT by default
- Text:
- FW_RStringData; // Initial text (odfrc bug: FW_RStringData must be the last field)
- };
-
- //========================================================================================
- // type FW_RPrivBaseScroller
- //========================================================================================
-
- type FW_RPrivBaseScroller : FW_RArchivableObject(Label='bscl')
- {
- };
-
- //========================================================================================
- // type FW_RScroller
- //========================================================================================
-
- type FW_RScroller : FW_RPrivBaseScroller(Label='sclr')
- {
- // Hidden fields to keep a reference to the frame used during the scroller initialization
- integer = FW_kPrivIDOnly;
- EnclosureFrameClass:
- longint = FW_kPrivNULLObjectID;
- integer = FW_kPrivIDOnly;
- EnclosureFrameID:
- longint = FW_kPreregisteredFrameObject;
-
- // ----- FW_RScroller fields
- // (odfrc bug: the Fixed field must come before the Point field)
- AutoScrollInset:
- FW_RFixed; // Use 0 or FW_FIX(a)
- AutoScrollIncrement:
- FW_RPoint; // {0,0} -> no auto-scroll, or else { FW_FIX(h), FW_FIX(v) }
- };
-
- //========================================================================================
- // type FW_RScrollBarScroller
- //========================================================================================
-
- type FW_RScrollBarScroller : FW_RScroller(Label='sbsc')
- {
- HorizViewID:
- longint; // Horizontal scrollbar id
- VertViewID:
- longint; // Vertical scrollbar id
- };
-
- //========================================================================================
- // type FW_RViewLayout
- //========================================================================================
- //
- // NOTE: Most parts will use FW_RFrameLayout (see below). FW_RViewLayout should only be
- // used if you are loading a view layout into a superview that is NOT a frame. If
- // FW_CFrame::CreateSubViewsFromStream is called for a stream that contains an
- // FW_RViewLayout then you'll get errors at runtime.
- //
-
- type FW_RViewLayout(FW_kViewLayoutType)
- {
- // Variables used in FW_RRadioCluster to keep a reference back to this superview
- // [LSD] See problem described above in FW_RSuperView
- static gSuperViewClassID = FW_kPrivNULLObjectID;
- static gSuperViewObjectID = FW_kPreregisteredRootViewObject;
-
- // The LayoutSize defines a reference size for the SuperView or Frame.
- // Its value is not important because all the views will be resized at runtime
- // to adjust to the real frame size defined by the part. What is important is the
- // placement of the subviews relative to this reference size and their binding flags.
- LayoutSize:
- FW_RPoint;
-
- // List of SubViews
- Views:
- integer = $$CountOf(ViewArray);
- array ViewArray
- {
- FW_RView(ParentViewClass=FW_kPrivNULLObjectID, ParentViewID=FW_kPreregisteredRootViewObject);
- };
-
- #if 0
- // ODFRC bug: cannot add a second array in this resource type for now
- RadioClusters:
- integer = $$CountOf(RadioClusterArray);
- array RadioClusterArray
- {
- FW_RRadioCluster(ViewClass=FW_kPrivNULLObjectID, ViewID=FW_kPreregisteredRootViewObject);
- };
- #endif
- };
-
- //========================================================================================
- // type FW_RFrameLayout
- //========================================================================================
-
- type FW_RFrameLayout(FW_kViewLayoutType) : FW_RViewLayout
- {
- // By convention, a frame contains 0 or 1 scroller.
- // The only (convenient) way to have zero scrollers is with an array.
- // Declaring more than 1 scroller will result in a runtime error (assert)
- integer = $$CountOf(ScrollerArray);
- array ScrollerArray
- {
- FW_RScroller;
- };
- };
-
- #endif
-